package rensoft.android.json;

import rensoft.java.json.JSONBoolean;
import rensoft.java.json.JSONTypeImpl;
import rensoft.java.json.JSONValue;


public class JSONBooleanImpl extends JSONTypeImpl implements JSONBoolean {

  private static JSONBooleanImpl TRUE = new JSONBooleanImpl(true);
  private static JSONBooleanImpl FALSE = new JSONBooleanImpl(false);

  public static JSONBoolean getInstance(boolean value) {
    if (value) return TRUE;
    return FALSE;
  }

  private final Boolean value;

  JSONBooleanImpl(Boolean value) {
    super(value);
    this.value = value;
  }

  @Override
  public JSONBoolean asBoolean() {
    return this;
  }

  @Override
  public JSONValue<Boolean> asValue() {
    return this;
  }

  public Boolean get() {
    return value.booleanValue();
  }
}
